// Copyright 2010, Vanya Davidenko.
// Используемая кодировка: UTF-8.

#ifndef SCRW_TESTING_BASE64_TESTING_H_
#define SCRW_TESTING_BASE64_TESTING_H_

#include <string>
#include <gtest/gtest.h>
#include "base64.h"


namespace scrw
{

namespace testing
{
class Base64Test : public ::testing::Test
{
  protected:
    Base64 b;

    virtual void SetUp()
    {
    }


    virtual void TearDown()
    {
    }
};

TEST_F(Base64Test, Precond)
{
    EXPECT_THROW(b.Encode(NULL, 0), libv::PrecondException);
}


TEST_F(Base64Test, Encode)
{
    const char c = 0;
    EXPECT_STREQ("", b.Encode(&c, NULL).c_str());
    EXPECT_STREQ("", b.Encode(::std::vector<char>()).c_str());

    EXPECT_STREQ("SA==", b.Encode("H", 1).c_str());
    EXPECT_STREQ("SGU=", b.Encode("He", 2).c_str());
    EXPECT_STREQ("SGVs", b.Encode("Hel", 3).c_str());

    EXPECT_STREQ("SGVsbG8gd29ybGQh",
                 b.Encode("Hello world!", 12).c_str());

    EXPECT_STREQ("SGVsbG8gd29ybGQhIQ==",
                 b.Encode("Hello world!!", 13).c_str());

    EXPECT_STREQ("SGVsbG8gd29ybGQhISE=",
                 b.Encode("Hello world!!!", 14).c_str());

}

}

}

#endif  // SCRW_TESTING_BASE64_TESTING_H_
